package com.scriptback.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.UUID;


/**
 * 项目实体类
 */
@Table(name = "projects")
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Project {

    @Id
    String id; // 项目ID
    
    @Column(name = "name",nullable = false,unique = true,length = 100)
    String name; // 项目名称
    
    @Column(name = "description",columnDefinition = "TEXT")
    String description; // 项目描述


    public Project(String name, String description){

        this.name=name;
        this.description=description;

    }

    // 在保存前自动生成UUID
    @PrePersist
    public void generateId() {
        if (this.id == null) {
            this.id = UUID.randomUUID().toString();
        }
    }
}
